/*     *//*
 package org.drools.core.rule.constraint;
*/
/*     *//*

*/
/*     *//*
 import java.util.HashMap;
*/
/*     *//*
 import java.util.Map;
*/
/*     *//*
 import org.drools.core.base.EvaluatorWrapper;
*/
/*     *//*
 import org.drools.core.base.mvel.MVELCompilationUnit;
*/
/*     *//*
 import org.drools.core.common.InternalFactHandle;
*/
/*     *//*
 import org.drools.core.common.InternalWorkingMemory;
*/
/*     *//*
 import org.drools.core.rule.Declaration;
*/
/*     *//*
 import org.drools.core.spi.Tuple;
*/
/*     *//*
 import org.drools.core.util.MVELSafeHelper;
*/
/*     *//*
 import org.kie.api.definition.rule.Rule;
*/
/*     *//*
 import org.mvel2.MVEL;
*/
/*     *//*
 import org.mvel2.ParserConfiguration;
*/
/*     *//*
 import org.mvel2.ParserContext;
*/
/*     *//*
 import org.mvel2.ast.ASTNode;
*/
/*     *//*
 import org.mvel2.ast.BooleanNode;
*/
/*     *//*
 import org.mvel2.ast.Contains;
*/
/*     *//*
 import org.mvel2.ast.Negation;
*/
/*     *//*
 import org.mvel2.ast.Substatement;
*/
/*     *//*
 import org.mvel2.compiler.CompiledExpression;
*/
/*     *//*
 import org.mvel2.compiler.ExecutableAccessor;
*/
/*     *//*
 import org.mvel2.compiler.ExecutableStatement;
*/
/*     *//*
 import org.mvel2.integration.VariableResolverFactory;
*/
/*     *//*
 import org.mvel2.util.ASTLinkedList;
*/
/*     *//*
 import org.slf4j.Logger;
*/
/*     *//*
 import org.slf4j.LoggerFactory;
*/
/*     *//*

*/
/*     *//*

*/
/*     *//*

*/
/*     *//*

*/
/*     *//*
 public class MvelConditionEvaluator
*/
/*     *//*
   implements ConditionEvaluator
*/
/*     *//*
 {
*/
/*     *//*
   protected final Declaration[] declarations;
*/
/*     *//*
   private final EvaluatorWrapper[] operators;
*/
/*     *//*
   private final String conditionClass;
*/
/*     *//*
   private final ParserConfiguration parserConfiguration;
*/
/*     *//*
   protected ExecutableStatement executableStatement;
*/
/*     *//*
   protected MVELCompilationUnit compilationUnit;
*/
/*     *//*
   private boolean evaluated;
*/
/*  42 *//*
   private static final Logger LOGGER = LoggerFactory.getLogger(MvelConditionEvaluator.class);
*/
/*     *//*

*/
/*     *//*
   public MvelConditionEvaluator(ParserConfiguration configuration, String expression, Declaration[] declarations, EvaluatorWrapper[] operators, String conditionClass) {
*/
/*  45 *//*
     this((MVELCompilationUnit)null, configuration, (ExecutableStatement)MVEL.compileExpression(expression, new ParserContext(configuration)), declarations, operators, conditionClass);
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   public MvelConditionEvaluator(MVELCompilationUnit compilationUnit, ParserConfiguration parserConfiguration, ExecutableStatement executableStatement, Declaration[] declarations, EvaluatorWrapper[] operators, String conditionClass) {
*/
/*  49 *//*
     this.evaluated = false;
*/
/*  50 *//*
     this.declarations = declarations;
*/
/*  51 *//*
     this.operators = operators;
*/
/*  52 *//*
     this.conditionClass = conditionClass;
*/
/*  53 *//*
     this.compilationUnit = compilationUnit;
*/
/*  54 *//*
     this.parserConfiguration = parserConfiguration;
*/
/*  55 *//*
     this.executableStatement = executableStatement;
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   public boolean evaluate(InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple tuple) {
*/
/*  59 *//*
     if (this.executableStatement instanceof CompiledExpression) {
*/
/*  60 *//*
       CompiledExpression executableStatement = (CompiledExpression)this.executableStatement;
*/
/*  61 *//*
       LOGGER.info("条件计算，sourceName：{},", executableStatement.getSourceName());
*/
/*     *//*
     }
*/
/*     *//*

*/
/*  64 *//*
     return evaluate(this.executableStatement, handle, workingMemory, tuple);
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   public boolean evaluate(ExecutableStatement statement, InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple tuple) {
*/
/*  68 *//*
     if (this.compilationUnit != null) {
*/
/*  69 *//*
       VariableResolverFactory factory = this.compilationUnit.createFactory();
*/
/*  70 *//*
       this.compilationUnit.updateFactory(null, (Rule)null, handle, tuple, (Object[])null, workingMemory, workingMemory.getGlobalResolver(), factory);
*/
/*  71 *//*
       return ((Boolean)MVELSafeHelper.getEvaluator().executeExpression(statement, handle.getObject(), factory)).booleanValue();
*/
/*     *//*
     }
*/
/*  73 *//*
     Map<String, Object> vars = EvaluatorHelper.valuesAsMap(handle.getObject(), workingMemory, tuple, this.declarations);
*/
/*  74 *//*
     if (this.operators.length > 0) {
*/
/*  75 *//*
       if (vars == null) {
*/
/*  76 *//*
         vars = new HashMap<>();
*/
/*     *//*
       }
*/
/*     *//*

*/
/*  79 *//*
       InternalFactHandle[] handles = (tuple != null) ? tuple.toFactHandles() : new InternalFactHandle[0];
*/
/*  80 *//*
       EvaluatorWrapper[] arr$ = this.operators;
*/
/*  81 *//*
       int len$ = arr$.length;
*/
/*     *//*

*/
/*  83 *//*
       for (int i$ = 0; i$ < len$; i$++) {
*/
/*  84 *//*
         EvaluatorWrapper operator = arr$[i$];
*/
/*  85 *//*
         vars.put(operator.getBindingName(), operator);
*/
/*  86 *//*
         operator.loadHandles(workingMemory, handles, handle);
*/
/*     *//*
       }
*/
/*     *//*
     }
*/
/*     *//*

*/
/*  90 *//*
     return evaluate(statement, handle.getObject(), vars);
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*

*/
/*     *//*
   private boolean evaluate(ExecutableStatement statement, Object object, Map<String, Object> vars) {
*/
/*  95 *//*
     return ((vars == null) ? (Boolean)MVELSafeHelper.getEvaluator().executeExpression(statement, object) : (Boolean)MVELSafeHelper.getEvaluator().executeExpression(statement, object, vars)).booleanValue();
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   ConditionAnalyzer.Condition getAnalyzedCondition() {
*/
/*  99 *//*
     return (new ConditionAnalyzer(this.executableStatement, this.declarations, this.operators, this.conditionClass)).analyzeCondition();
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   ConditionAnalyzer.Condition getAnalyzedCondition(InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple leftTuple) {
*/
/* 103 *//*
     ensureCompleteEvaluation(handle, workingMemory, leftTuple);
*/
/* 104 *//*
     return (new ConditionAnalyzer(this.executableStatement, this.declarations, this.operators, this.conditionClass)).analyzeCondition();
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   private void ensureCompleteEvaluation(InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple tuple) {
*/
/* 108 *//*
     if (!this.evaluated) {
*/
/* 109 *//*
       ASTNode rootNode = getRootNode();
*/
/* 110 *//*
       if (rootNode != null) {
*/
/* 111 *//*
         ensureCompleteEvaluation(rootNode, handle, workingMemory, tuple);
*/
/*     *//*
       }
*/
/*     *//*

*/
/* 114 *//*
       this.evaluated = true;
*/
/*     *//*
     }
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*

*/
/*     *//*
   private void ensureCompleteEvaluation(ASTNode node, InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple tuple) {
*/
/* 120 *//*
     node = unwrap(node);
*/
/* 121 *//*
     if (node instanceof org.mvel2.ast.And || node instanceof org.mvel2.ast.Or) {
*/
/* 122 *//*
       ensureBranchEvaluation(handle, workingMemory, tuple, ((BooleanNode)node).getLeft());
*/
/* 123 *//*
       ensureBranchEvaluation(handle, workingMemory, tuple, ((BooleanNode)node).getRight());
*/
/*     *//*
     }
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   private ASTNode unwrap(ASTNode node) {
*/
/* 128 *//*
     while (node instanceof Negation || node instanceof org.mvel2.ast.LineLabel || node instanceof Substatement) {
*/
/* 129 *//*
       node = unwrapNegation(node);
*/
/* 130 *//*
       node = unwrapSubstatement(node);
*/
/*     *//*
     }
*/
/*     *//*

*/
/* 133 *//*
     return node;
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   private void ensureBranchEvaluation(InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple tuple, ASTNode node) {
*/
/* 137 *//*
     if (!isEvaluated(node)) {
*/
/* 138 *//*
       ASTNode next = node.nextASTNode;
*/
/* 139 *//*
       node.nextASTNode = null;
*/
/* 140 *//*
       evaluate((ExecutableStatement)asCompiledExpression(node), handle, workingMemory, tuple);
*/
/* 141 *//*
       node.nextASTNode = next;
*/
/*     *//*
     }
*/
/*     *//*

*/
/* 144 *//*
     ensureCompleteEvaluation(node, handle, workingMemory, tuple);
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   private ASTNode unwrapNegation(ASTNode node) {
*/
/* 148 *//*
     if (node instanceof Negation) {
*/
/* 149 *//*
       ExecutableStatement statement = ((Negation)node).getStatement();
*/
/* 150 *//*
       return (statement instanceof ExecutableAccessor) ? ((ExecutableAccessor)statement).getNode() : null;
*/
/*     *//*
     }
*/
/* 152 *//*
     return node;
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*

*/
/*     *//*
   private ASTNode unwrapSubstatement(ASTNode node) {
*/
/* 157 *//*
     if (node instanceof org.mvel2.ast.LineLabel) {
*/
/* 158 *//*
       return node.nextASTNode;
*/
/*     *//*
     }
*/
/* 160 *//*
     return (node instanceof Substatement) ? ((ExecutableAccessor)((Substatement)node).getStatement()).getNode() : node;
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*

*/
/*     *//*
   private boolean isEvaluated(ASTNode node) {
*/
/* 165 *//*
     node = unwrapSubstatement(node);
*/
/* 166 *//*
     if (node instanceof Contains) {
*/
/* 167 *//*
       return (((Contains)node).getFirstStatement().getAccessor() != null);
*/
/*     *//*
     }
*/
/* 169 *//*
     return (node instanceof org.mvel2.ast.BinaryOperation) ? ((((BooleanNode)node).getLeft().getAccessor() != null)) : ((node.getAccessor() != null));
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*

*/
/*     *//*
   private CompiledExpression asCompiledExpression(ASTNode node) {
*/
/* 174 *//*
     return new CompiledExpression(new ASTLinkedList(node), (String)null, Object.class, this.parserConfiguration, false);
*/
/*     *//*
   }
*/
/*     *//*

*/
/*     *//*
   private ASTNode getRootNode() {
*/
/* 178 *//*
     if (this.executableStatement instanceof org.mvel2.compiler.ExecutableLiteral) {
*/
/* 179 *//*
       return null;
*/
/*     *//*
     }
*/
/* 181 *//*
     return (this.executableStatement instanceof CompiledExpression) ? ((CompiledExpression)this.executableStatement).getFirstNode() : ((ExecutableAccessor)this.executableStatement).getNode();
*/
/*     *//*
   }
*/
/*     *//*
 }


*/
/* Location:              D:\apache-tomcat-9.0.76\webapps\grule-manager\WEB-INF\lib\grule-client-2.0.2.RELEASE.jar!\org\drools\core\rule\constraint\MvelConditionEvaluator.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */
